package com.framework.network.interceptor.urlinter

import okhttp3.HttpUrl
import okhttp3.HttpUrl.Companion.toHttpUrlOrNull

/**
 * 工具类
 */
class CheckUrlUtils private constructor() {
    
    init {
        throw IllegalStateException("do not instantiation me")
    }
    
    companion object {
        fun checkUrl(url: String): HttpUrl {
            val parseUrl = url.toHttpUrlOrNull()
            return parseUrl ?: throw InvalidUrlException(url)
        }
        
        fun <T> checkNotNull(`object`: T?, message: String): T {
            if (`object` == null) {
                throw NullPointerException(message)
            }
            return `object`
        }
    }
}
